package ar.com.ford.it.fullEconomics.persistence.dao.query;

import oracle.toplink.expressions.Expression;
import oracle.toplink.expressions.ExpressionBuilder;
import ar.com.ford.it.fullEconomics.persistence.dto.Teesg01Plant;
import com.ford.it.persistence.impl.toplink.CustomExpressionFactory;

public class PartsByLowCommFindQuery implements CustomExpressionFactory {

    public Expression createExpression(ExpressionBuilder builder,
                                       Object[] parameters) {
        Expression exp = null;
        String lowCom = (String) parameters[0];
        Teesg01Plant plant = (Teesg01Plant) parameters[1];



        exp = builder.get("eesp01PlantCodeC").equal(plant);
        if (lowCom != null) {
            lowCom += "%";
            exp = exp.and(builder.get("eesp01PartCommodLowCodeC").toChar().like(
                    lowCom));
        }
        return exp;
    }

}
